﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace com.hk.validate.Common
{
    public class DataLengthValidator : IValidate
    {
        public DataLengthValidator(object toValidate,int limitLength)
        {
            this.toValidate = toValidate;
            this.LimitLength = limitLength;
        }
        
        public bool Validate()
        {
            if (this.toValidate.GetType().ToString().Equals("System.String"))
            {
                int i = this.toValidate.ToString().Length;
                if (i > this.LimitLength)
                {
                    return false;
                }
            }
            return true;
        }

        public object toValidate
        {
            get { return _toValidate; }
            set { _toValidate=value; }
        }

        public int LimitLength
        {
            get { return _limitLength; }
            set { _limitLength=value; }
        }

        private object _toValidate;
        private int _limitLength;
    }
}
